import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.koin.core.qualifier.named
import org.slf4j.Logger

class MainHandler private constructor() : KoinComponent {
    private val logInfo: Logger by inject(named("Info"))
    private val logError: Logger by inject(named("Error"))
    private val botModelImpl: BotModel by inject()


    init {
        logInfo.info("Starting bot")
        try {
            botModelImpl.getBot().startPolling()
        } catch (e: Exception) {
            logError.error("Error starting the bot", e)
        }

        logInfo.info("Bot started")
    }

    companion object {
        fun createAndStart() {
            MainHandler()
        }
    }
}
